<?php $this->set('title', 'Survey Results'); ?>

<!-- Survey Results Links -->
<b>Survey Results</b><br />
<?php echo $html->link("Individual", array('controller' => 'presenters', 'action' => 'search_audience')); ?> | 
<?php echo $html->link("Group", array('controller' => 'presenters', 'action' => 'group_results')); ?>

<div class="header"><?php echo($user_firstname.' '.$user_lastname."'s Surveys"); ?></div>

<?php if(!$display) { ?>
	<br />
	<b>This user has not registered for any surveys</b>
	<br />
<?php } else { ?>

<table>
	<?php echo $form->create('Users', array('action' => 'select_survey')); ?>
		<td>	
			<?php echo $form->select('Survey.id', $options, $survey_id, null, false); ?>
			<?php echo $form->hidden('User.id', array('value' => $user_id)); ?>
		</td>
		<td>
			<?php echo $form->end('Submit'); ?>
		</td>
</table>
<br />

<div class="header"><?php echo("Survey ".'"'.$survey_name.'"'." Responses"); ?></div>

<?php $index = 1;
	foreach( $question_texts as $question_text){
		echo('<p>'.($index).'. '.$question_text."<br />\n");
		echo('<span style="position:relative; left:30px;">');
		
		// For each response in the set of responses for the current question...
		$index2 = 0;
		foreach($possible_responses[$index - 1] as $possible_response){
			// set to true if the response being iterated over is the one the user selected
			$response_was_users = false;
			if($possible_response['id'] == $user_response_ids[$index - 1])
				$response_was_users = true;
			
			if($response_was_users){ 
				echo($html->image("icons/gem_okay.png")); 
				echo('<font color="green">'); 
			}
			else{
				echo($html->image("icons/gem_cancel_2.png"));
			}
			
//			echo($possible_response['text']);
			echo(chr(($index2++)+65).'. '.$possible_response['text']);
			if($response_was_users) echo('</font>');
			
			echo('<br>');
		}
		
		// If there was an invalid / non response
		if($user_response_ids[$index - 1] < 0){
			echo('<b><font color="red">');
//			echo($user_firstname.' '.$user_lastname.' did not submit a response to this question');
			echo('<div style="padding-top:5px;padding-bottom:5px;">No response</div>');
			echo('</font></b>');
//			echo('<br>');
		}
		echo('</span>');
		echo('</p>');
		$index = $index + 1; 
	} ?>
	
<?php } ?>
